{% extends '@WebsiteBundle/layout/layout.html.twig' %}

{% block page %}
  {{ parent() }}

  <div id="main" class="commonMain">
    <div class="layui-main addbuy">
      <div class="wrap">
        <div class="content">
          <div class="layui-row">
            <div class="layui-col-md-offset4"></div>
            <div class="layui-col-md-offset4">
              <div id="qrcode"></div>
            </div>
            <div class="layui-col-md-offset4"></div>
          </div>
          <div class="layui-row margin-top20">
            <div class="layui-col-md-offset4"></div>
            <div class="layui-col-md-offset4">
              请用微信扫描二维码完成支付
            </div>
            <div class="layui-col-md-offset4"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
{% endblock %}

{% block body_javascript %}
  {{ parent() }}
  <script src="{{ asset('bundles/eduxpluswebsite/plugins/qrcode/qrcode.min.js') }}"></script>
  <script>
    $(function(){
      var qrcode = new QRCode(document.getElementById("qrcode"), {
        text: '{{ body["code_url"] }}',
        width: 250,
        height: 250,
        colorDark : "#000000",
        colorLight : "#ffffff",
        correctLevel : QRCode.CorrectLevel.H
      });
    });

    function wxpayCheck(){
      var url = "{{ path("app_order_wxpayCheck", {orderNo:orderNo}) }}";
      $.getJSON(url,{},function(responseText){
        if (typeof responseText == "string")
          var responseText = $.parseJSON(responseText);
        if ((responseText.code == 200) && (responseText.data.status==1)) {
          location.assign("{{ path('app_order_paysuccess', {orderNo:orderNo}) }}");
        }
      });
    }
    setInterval('wxpayCheck()',2000);

  </script>
{% endblock %}
